package com.demo.auth.service.remote.impl;

import com.demo.auth.service.remote.DispatchRemoteAuthUserService;
import com.demo.common.base.constant.SysConstant;
import com.demo.common.base.pojo.JsonRes;
import com.demo.user.remote.RemoteAuthUserService;
import com.demo.user.vo.AuthUserVO;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Objects;

/**
 * @author DayDayUp
 * create on 2023-08-16
 **/
@Service
public class DispatchRemoteAuthUserServiceImpl implements DispatchRemoteAuthUserService {

    @Resource
    private RemoteAuthUserService remoteAuthUserService;

    @Override
    public AuthUserVO getUserByUsername(String username) {
        JsonRes<AuthUserVO> jsonRes = remoteAuthUserService.getUserByUsername(username);
        if (Objects.isNull(jsonRes) || !Objects.equals(SysConstant.SUCCESS, jsonRes.getStatus())) {
            return null;
        }
        return jsonRes.getData();
    }
}
